import React, { useState, useEffect } from 'react';

const Counter = () => {
    const [count, setCount] = useState(0);

    const add = () => {
        setCount(count + 1)
    }

    const handleAlertClick = () => {
        setTimeout(() => {
            alert('You clicked on: ' + count);
        }, 3000)
    }

    useEffect(() => {
        document.title = `You Click ${count} times`;
    })

    return (
        <div>
            <p>You clicked {count} times</p>
            <button onClick={() => add()}>Click me</button>
            <button onClick={handleAlertClick}>Show alert</button>
        </div>
    )
}

export default Counter;
